﻿using System;

namespace Joy.Erp.BasicArchives.SerialNumbers
{
    public static class SerialNumberExtensions
    {
        public static bool IsCurrentYear(this SerialNumber serialNumber)
        {
            var serialNumberYear = serialNumber.LastModificationTime?.Year ?? serialNumber.CreationTime.Year;
            return DateTime.Now.Year == serialNumberYear;
        }
        public static bool IsCurrentMonth(this SerialNumber serialNumber)
        {
            var serialNumberMonth = serialNumber.LastModificationTime?.Month ?? serialNumber.CreationTime.Month;
            return serialNumber.IsCurrentYear() && DateTime.Now.Month == serialNumberMonth;
        }
        public static bool IsCurrentDay(this SerialNumber serialNumber)
        {
            var serialNumberDay = serialNumber.LastModificationTime?.Day ?? serialNumber.CreationTime.Day;
            return serialNumber.IsCurrentMonth() && DateTime.Now.Month == serialNumberDay;
        }
        public static bool IsCurrentHour(this SerialNumber serialNumber)
        {
            var serialNumberHour = serialNumber.LastModificationTime?.Hour ?? serialNumber.CreationTime.Hour;
            return serialNumber.IsCurrentDay() && DateTime.Now.Month == serialNumberHour;
        }
        public static bool IsCurrentMinute(this SerialNumber serialNumber)
        {
            var serialNumberMinute = serialNumber.LastModificationTime?.Minute ?? serialNumber.CreationTime.Minute;
            return serialNumber.IsCurrentHour() && DateTime.Now.Month == serialNumberMinute;
        }
        public static bool IsCurrentSecond(this SerialNumber serialNumber)
        {
            var serialNumberSecond = serialNumber.LastModificationTime?.Second ?? serialNumber.CreationTime.Second;
            return serialNumber.IsCurrentMinute() && DateTime.Now.Month == serialNumberSecond;
        }
    }
}
